{include file="public/headerbase" /} {include file="public/left" /}
<script src="__PUBLIC__/ppy/js/jquery.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/ppy/js/bootstrap.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/ppy/css/bootstrap.min.css">
<link href="__PUBLIC__/ppy/css/fileinput.css" media="all" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/ppy/js/fileinput.js" type="text/javascript"></script>
<script src="__PUBLIC__/ppy/js/fileinput_locale_zh.js" type="text/javascript"></script>
<div class="right-content">
	<ol class="breadcrumb we7-breadcrumb">
		<li>
			<a href="{:url('Goods/index')}">商品展示</a>
		</li>
		<li>
			添加商品
		</li>
	</ol>
	<div class="clearfix">
		<form action="{:url('Goods/addxinx')}" method="post" class="we7-form" role="form" id="form1" enctype="multipart/form-data">
		<!-- 	<div class="form-group">
				<label class="col-sm-2 control-label">商品展示图</label>
				<div class="col-sm-8">
				<input type="file" name="goodshow[]" id="file0" multiple="multiple" style="display: inline-block;" />
				<span style="color: red">*图片尺寸750*425</span>
				<br>
				<input type="file" name="goodshow" id="file0" multiple="multiple"/><br> 
				<img src="__PUBLIC__/images/img.jpg" id="img0" style="height:100px;">
				<div id="demo" class="demo" ></div> 
					<input type="hidden" name="imagesSrc" value=""  id="imgDetail">
				</div>
			</div> -->

			<div class="form-group">
				<label class="col-sm-2 control-label">商品展示图</label><br><br>
                            <input id="file-5" name="pic_all[]" type="file"  class="file"  multiple data-preview-file-type="any" data-upload-url="#" data-preview-file-icon=""><br />
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label">商品缩略图</label>
				<div class="col-sm-8">
				<input type="file" name="goodsthumb" id="file1" multiple="multiple" style="display: inline-block;"/>
				<span style="color: red">*图片尺寸220*220</span>
				<br>
				<img src="__PUBLIC__/images/img.jpg" id="img1" style="height:100px;">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">商品标题</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" name="gtitle" id="gtitle" value="" placeholder="商品标题" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">商品品牌</label>
				<div class="col-sm-8">
					<select name="gbrand" class="form-control">
						<option value="0">==请选择商品品牌==</option>
						{foreach name="brand" item="val"}
							<option value="{$val.bid}">{$val['bname']}</option>
						{/foreach}
					</select>	
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">商品分类</label>
				<div class="col-sm-8">
					<select name="gcate" class="form-control">
						<option value="0">==请选择商品分类==</option>
						{foreach name="category" item="val"}
							<option value="{$val.cid}">{$val['cname']}</option>
						{/foreach}
					</select>	
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">库存</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" name="goodsnum" id="goodsnum" value="" placeholder="库存" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">运费</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" name="gfare" id="gfare" value="" placeholder="运费" />
				</div>
			</div>
			<!-- 添加规格开始 -->
				<div id="tpl" style="clear:both;">
					<div class="form-group" style="width:31%;float:left">
						<label class="col-xs-12 col-sm-2 col-md-2 control-label" style="width:59%;;">商品规格</label>
						<div class="col-sm-8" style="width:40%;margin:0;padding:0;">
							<input type="text" class="form-control" name="sspec[]" id="sspec" vlaue="" placeholder="商品规格"/>
						</div>
					</div>
					<div class="form-group" style="width:23%;float:left;padding:0;margin-left:2%;">
						<label class="col-xs-12 col-sm-2 col-md-2 control-label" style="width:18%;margin:0;">价格</label>
						<div class="col-sm-8" style="width:60%;margin:0;padding:0;">
							<input type="text" class="form-control" name="sprice[]" id="sprice" vlaue="" placeholder="每一个规格价格"/>
						</div>
					</div>
					<div class="form-group" style="width:25%;float:left;padding:0;margin:0;">
						<label class="col-xs-12 col-sm-2 col-md-2 control-label" style="width:28%;margin:0;">规格数量</label>
						<div class="col-sm-8" style="width:55%;margin:0;padding:0;">
							<input type="text" class="form-control" name="snum[]" id="snum" vlaue="" placeholder="每一个规格数量"/>
						</div>
					</div>
					<div class="tu" style="width:3%;float:left;">
						<img src="/static/images/del.png" alt="" style="width:100%;margin-top:7px;" onclick="delect(this)">
					</div>
					<hr/  style="clear:both;width:85%;margin-left:0;">
				</div>
				<div id="container"></div>
				<div class="form-group">
					<label class="col-sm-2 control-label"></label>
					<div class="col-sm-8">
						<a href="javascript:;" id="category-add"><i class="fa fa-plus-circle"></i> 继续添加规格</a>
					</div>
				</div>
			<!-- 添加规格结束 -->
		<!-- 	<div class="form-group">
				<label class="col-sm-2 control-label">详情图片</label>
				<div class="col-sm-8">
				<div id="demo" class="demo" ></div> 
					<input type="hidden" name="imagesSrc" value=""  id="imgDetail">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">商品详情</label>
				<div class="col-sm-8">
					<textarea name="goodstext" style="width:590px;" placeholder="商品详情"></textarea>
				</div>
			</div> -->
			<div class="form-group">
   				
   				<div class="col-sm-2 control-label" >商品详情
   				<div style="display: block;color:red">图片尺寸750*425</div>
   				</div>
   				
   				<div class="col-sm-8">
   				 	<script id="editor" type="text/plain" style="width:750px;height:400px;"></script>
   				</div>
			</div>
			<div style="position:absolute;left:410px;top:120px;display: none" id="imgUpload">
			<div id="demo" class="demo" ></div> 
				
				
			</div>
			<div class="form-group">
				<div class="">
					<input type="submit" class="btn btn-primary" value="提交" />
					<a href="{:url('Brand/index')}"><button type="button" class="btn btn-success">取消</button>
				</div>
			</div>
			
		</form>
		
		</div>
	</div>

	<script>
		$(function(){
			$('#quxiao').click(function(){
				$('#imgUpload').hide();
			})
			$("#imgDetail").click(function(){
				$('#imgUpload').show();
			})
		})
		$(function(){
			$('#category-add').click(function(){
				var div=$("<div></div>")
				var html = $('#tpl').html();
				$('#container').append(div);
				div.append(html);
				return false;
			});
		});
		$(function(){
			$('#category-add1').click(function(){
				var html = $('#tpl1').html();
				$('#container1').append(html);
				return false;
			});
		});
	</script>	
	<script>
	$("#file0").change(function(){
			var objUrl = getObjectURL(this.files[0]) ;
			console.log("objUrl = "+objUrl) ;
			if (objUrl) {
			$("#img0").attr("src", objUrl) ;
			}
		}) ;
		//建立一個可存取到該file的url
		function getObjectURL(file) {
			var url = null ; 
			if (window.createObjectURL!=undefined) { // basic
				url = window.createObjectURL(file) ;
			} else if (window.URL!=undefined) { // mozilla(firefox)
				url = window.URL.createObjectURL(file) ;
			} else if (window.webkitURL!=undefined) { // webkit or chrome
				url = window.webkitURL.createObjectURL(file) ;
			}
			return url ;
		}
		$("#file1").change(function(){
			var objUrl = getObjectURL(this.files[0]) ;
			console.log("objUrl = "+objUrl) ;
			if (objUrl) {
			$("#img1").attr("src", objUrl) ;
			}
		}) ;
		//建立一個可存取到該file的url
		function getObjectURL(file) {
			var url = null ; 
			if (window.createObjectURL!=undefined) { // basic
				url = window.createObjectURL(file) ;
			} else if (window.URL!=undefined) { // mozilla(firefox)
				url = window.URL.createObjectURL(file) ;
			} else if (window.webkitURL!=undefined) { // webkit or chrome
				url = window.webkitURL.createObjectURL(file) ;
			}
			return url ;
		}
		$("#file2").change(function(){
			var objUrl = getObjectURL(this.files[0]) ;
			console.log("objUrl = "+objUrl) ;
			if (objUrl) {
			$("#img2").attr("src", objUrl) ;
			}
		}) ;
		//建立一個可存取到該file的url
		function getObjectURL(file) {
			var url = null ; 
			if (window.createObjectURL!=undefined) { // basic
				url = window.createObjectURL(file) ;
			} else if (window.URL!=undefined) { // mozilla(firefox)
				url = window.URL.createObjectURL(file) ;
			} else if (window.webkitURL!=undefined) { // webkit or chrome
				url = window.webkitURL.createObjectURL(file) ;
			}
			return url ;
		}
		function delect(obj){
			if(!confirm('确定删除吗')){
			return false;
		}
	    obj.parentNode.parentNode.remove();
		}
	</script>
	<script type="text/javascript">

    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例

    var ue = UE.getEditor('editor');
    
   

    function isFocus(e){
        alert(UE.getEditor('editor').isFocus());
        UE.dom.domUtils.preventDefault(e)
    }
    function setblur(e){
        UE.getEditor('editor').blur();
        UE.dom.domUtils.preventDefault(e)
    }
    function insertHtml() {
        var value = prompt('插入html代码', '');
        UE.getEditor('editor').execCommand('insertHtml', value)
    }
    function createEditor() {
        enableBtn();
        UE.getEditor('editor');
    }
    function getAllHtml() {
        alert(UE.getEditor('editor').getAllHtml())
    }
    function getContent() {
        var arr = [];
        arr.push("使用editor.getContent()方法可以获得编辑器的内容");
        arr.push("内容为：");
        arr.push(UE.getEditor('editor').getContent());
        alert(arr.join("\n"));
    }
    function getPlainTxt() {
        var arr = [];
        arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
        arr.push("内容为：");
        arr.push(UE.getEditor('editor').getPlainTxt());
        alert(arr.join('\n'))
    }
    function setContent(isAppendTo) {
        var arr = [];
       
        arr.push(isAppendTo);
        UE.getEditor('editor').setContent(isAppendTo);
        //alert(arr.join("\n"));
    }
    function setDisabled() {
        UE.getEditor('editor').setDisabled('fullscreen');
        disableBtn("enable");
    }

    function setEnabled() {
        UE.getEditor('editor').setEnabled();
        enableBtn();
    }

    function getText() {
        //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
        var range = UE.getEditor('editor').selection.getRange();
        range.select();
        var txt = UE.getEditor('editor').selection.getText();
        alert(txt)
    }

    function getContentTxt() {
        var arr = [];
        arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
        arr.push("编辑器的纯文本内容为：");
        arr.push(UE.getEditor('editor').getContentTxt());
        alert(arr.join("\n"));
    }
    function hasContent() {
        var arr = [];
        arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
        arr.push("判断结果为：");
        arr.push(UE.getEditor('editor').hasContents());
        alert(arr.join("\n"));
    }
    function setFocus() {
        UE.getEditor('editor').focus();
    }
    function deleteEditor() {
        disableBtn();
        UE.getEditor('editor').destroy();
    }
    function disableBtn(str) {
        var div = document.getElementById('btns');
        var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            if (btn.id == str) {
                UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
            } else {
                btn.setAttribute("disabled", "true");
            }
        }
    }
    function enableBtn() {
        var div = document.getElementById('btns');
        var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
        }
    }

    function getLocalData () {
        alert(UE.getEditor('editor').execCommand( "getlocaldata" ));
    }

    function clearLocalData () {
        UE.getEditor('editor').execCommand( "clearlocaldata" );
        alert("已清空草稿箱")
    }
</script>
</div>
</div>
</div>
</div>
</div>
{include file="public/footer" /}